<template>
  <div class="varios">
    <div class="label-name">
      {{ varName }}
    </div>
    <div class="variso-box">
      <div class="variso-item" v-for="(item, index) in varList" :key="index">
        <div>
          <div class="variso-img">
            <a :href="foodHref + varList[index].fid"
              ><img :src="varList[index].fimg" alt=""
            /></a>
          </div>

          <div>
            <div class="varios-name">
              <a :href="foodHref + varList[index].fid">{{
                varList[index].fname
              }}</a>
            </div>
            <div class="varios-nei">
              <a :href="foodHref + varList[index].fid">{{
                varList[index].fcontent
              }}</a>
            </div>
          </div>
        </div>
      </div>

      <div class="varios-ranking">
        <div class="varios-top">
          <div>排行榜</div>
          <div class="varios-more"><a :href="ftHref">更多</a></div>
        </div>
        <div
          class="varanking-item"
          v-for="(item, index) in rankingList"
          :key="index"
        >
          <div class="varanking-pai" :class="{ varankingTop: index <= 2 }">
            {{ index + 1 }}
          </div>
          <div>
            <a :href="foodHref + rankingList[index].fid">{{
              rankingList[index].fname
            }}</a>
          </div>
        </div>
      </div>
      <div></div>
    </div>
  </div>
</template>

<script>
import { request } from "../../network/request";
export default {
  name: "Various",
  data() {
    return {
      varList: "",
      rankingList: "",
      foodHref: "/showfood?fid=",
    };
  },
  props: {
    ftId: {
      type: Number,
      required: true,
    },
    varName: {
      type: String,
      required: true,
    },
    ftHref: {
      type: String,
      required: true,
    },
  },
  created: function () {
    request({
      url: "/firstpage/queryChineseFood",
      params: {
        ftId: this.ftId,
      },
    })
      .then((res) => {
        this.varList = res.data.data;
      })
      .catch((err) => {
        console.log(err);
      });

    request({
      url: "/firstpage/queryChineseFoodRanking",
      params: {
        ftId: this.ftId,
      },
    })
      .then((res) => {
        this.rankingList = res.data.data;
      })
      .catch((err) => {
        console.log(err);
      });
  },
};
</script>

<style>
.varios {
  width: 85%;
  margin: 0 auto;
  margin-bottom: 0.4rem;
}
.variso-box {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
}

.variso-item {
  width: 1.9rem;
  margin-top: 0.2rem;
  font-size: 0.12rem;
  margin-bottom: 0.4rem;
}

.variso-img {
  width: 1.9rem;
  height: 1.2rem;
  overflow: hidden;
  border-radius: 0.06rem;
}

.variso-img img {
  width: 1.9rem;
  height: 1.2rem;
  transition: all 0.3s;
}

.variso-img img:hover {
  transform: scale(1.1);
}

.variso-img:hover + div a {
  color: rgb(125, 214, 250);
}

.variso-img + div a:hover {
  color: rgb(125, 214, 250);
}

.varios-name {
  font-size: 0.125rem;
  margin-top: 0.12rem;
}

.varios-nei {
  font-size: 0.09rem;
  margin-top: 0.08rem;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.variso-item a {
  text-decoration: none;
  color: #000;
}

.varios-ranking {
  width: 1.3rem;
  margin-left: 0.25rem;
}

.varanking-item {
  font-size: 0.095rem;
  display: flex;
  margin-top: 0.1rem;
}

.varanking-item a {
  text-decoration: none;
  color: #000;
}

.varanking-item a:hover {
  color: rgb(125, 214, 250);
}

.varanking-pai {
  width: 0.18rem;
  height: 0.18rem;
  margin-right: 0.2rem;
  text-align: center;
  line-height: 0.18rem;
  border-radius: 0.02rem;
}

.varios-top {
  font-size: 0.13rem;
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.3rem;
  margin-top: -0.3rem;
}

.varios-more {
  width: 0.4rem;
  height: 0.15rem;
  line-height: 0.15rem;
  text-align: center;
  border: 1px solid slategray;
  border-radius: 0.035rem;
  font-size: 0.08rem;
  cursor: pointer;
}

.varios-more:hover {
  background-color: rgb(227, 229, 231);
}

.varios-top a {
  text-decoration: none;
  color: #000;
}

.varankingTop {
  background-color: rgb(0, 161, 214);
  color: #fff;
}
</style>